function JDisplay(  )
{
	flashpoint();
	
//DisplayLine ( "\x1A\x9A\x8A\xC3\xBD\xC4\x83\xDE\x1D\xA1" )
	var var1,var2,var3,var3,var4,var5,var6;

	printf('# Displays Japanese characters ');
	printf('# uses Display ');
	
	writeMenu('"DisplayJpn"','"CMD"','"JDisplay()"');
	printf('');

  for( i = 0x6 ; i<=0xff; i+=6){
  
  		if( i % 0x6 == 0){
  				 var2 = var3 = var4 = var5 = var6= decTohex(0xff);

  				var1= decTohex(i);
  				if(i+1 <= 0xff) var2= decTohex(i+1);  				
  				if(i+2 <= 0xff) var3= decTohex(i+2);  				
  				if(i+3 <= 0xff) var4= decTohex(i+3);  				
  				if(i+4 <= 0xff) var5= decTohex(i+4);  				
  				if(i+5 <= 0xff) var6= decTohex(i+5);
  				
  				if( i==0xde || i==0xdf ) var1=decTohex(0x20);
  				if( ((i+1)==0xde) || ((i+1)==0xdf) ) var2=decTohex(0x20);
  				if( ((i+2)==0xde) || ((i+2)==0xdf) ) var3=decTohex(0x20);
  				if( ((i+3)==0xde) || ((i+3)==0xdf) ) var4=decTohex(0x20);
  				if( ((i+4)==0xde) || ((i+4)==0xdf) ) var5=decTohex(0x20);
  				if( ((i+5)==0xde) || ((i+5)==0xdf) ) var6=decTohex(0x20);
  							
  				printf('Display("',var1,var2,var3,var4,var5,var6,'")' );  							
  				printf('DisplayLine(" ")' );  							
  				
  				printf('Wait(1000)');
		}

}
				
				printf('exitscript');


}


function JDisplayLine(  )
{
	flashpoint();
	
//DisplayLine ( "\x1A\x9A\x8A\xC3\xBD\xC4\x83\xDE\x1D\xA1" )
	var var1,var2,var3,var3,var4,var5,var6;

	printf('# Displays Japanese characters ');
	printf('# uses DisplayLine ');
	
	writeMenu('"DisplayJpn"','"EXTRA"','"JDisplayL()"');
	printf('');


  for( i = 0x6 ; i<=0xff; i+=6){
  
  		if( i % 0x6 == 0){
  				 var2 = var3 = var4 = var5 = var6= decTohex(0xff);

  				var1= decTohex(i);
  				if(i+1 <= 0xff) var2= decTohex(i+1);
  				if(i+2 <= 0xff) var3= decTohex(i+2);
  				if(i+3 <= 0xff) var4= decTohex(i+3);
  				if(i+4 <= 0xff) var5= decTohex(i+4);
  				if(i+5 <= 0xff) var6= decTohex(i+5);
  				
  				if( i==0xde || i==0xdf ) var1=decTohex(0x20);
  				if( ((i+1)==0xde) || ((i+1)==0xdf) ) var2=decTohex(0x20);
  				if( ((i+2)==0xde) || ((i+2)==0xdf) ) var3=decTohex(0x20);
  				if( ((i+3)==0xde) || ((i+3)==0xdf) ) var4=decTohex(0x20);
  				if( ((i+4)==0xde) || ((i+4)==0xdf) ) var5=decTohex(0x20);
  				if( ((i+5)==0xde) || ((i+5)==0xdf) ) var6=decTohex(0x20);
  							
  							
  				printf('DisplayLine("',var1,var2,var3,var4,var5,var6,'")' );  							
  				
  				printf('Wait(1000)');
		}

}
				
				printf('exitscript');


}



function JSetOption()
{
	flashpoint();

	var var1,var2,var3,var3,var4,var5,var6;
	
	printf('# Displays Japanese characters ');
	printf('# uses SetOption ');


	writeMenu('"DisplayJpn"','"EXTRA"','"JSOption()"');
	printf('declare u: choice');

	
 for( i = 0x6 ; i<=0xff; i+=6){
  
  		var2 = var3 = var4 = var5 = var6= decTohex(0xff);
  		
  		if( i % 0x6 == 0){
  				var1= decTohex(i);
  				if(i+1 <= 0xff) var2= decTohex(i+1);
  				if(i+2 <= 0xff) var3= decTohex(i+2);
  				if(i+3 <= 0xff) var4= decTohex(i+3);
  				if(i+4 <= 0xff) var5= decTohex(i+4);
  				if(i+5 <= 0xff) var6= decTohex(i+5);
  							
  				printf('SetOption(',i,',"',var1,var2,var3,var4,var5,var6,'")' );  							  				
		}
}		

				printf('GetOption(choice)');

				printf('exitscript');

}

function JAlert()
{
	flashpoint();

	var var1,var2,var3,var3,var4,var5,var6;
	
	printf('# Displays Japanese characters ');
	printf('# uses Alert() ');


	writeMenu('"DisplayJpn"','"EXTRA"','"JAlert()"');
	
 for( i = 0x6 ; i<=0xff; i+=6){
  
  		var2 = var3 = var4 = var5 = var6= decTohex(0xff);
  		
  		if( i % 0x6 == 0){
  				var1= decTohex(i);
  				if(i+1 <= 0xff) var2= decTohex(i+1);
  				if(i+2 <= 0xff) var3= decTohex(i+2);
  				if(i+3 <= 0xff) var4= decTohex(i+3);
  				if(i+4 <= 0xff) var5= decTohex(i+4);
  				if(i+5 <= 0xff) var6= decTohex(i+5);
  				printf('Alert("',var1,var2,var3,var4,var5,var6,'")' );  							  				
		}
}		


				printf('exitscript');

}

function JSpecialChars(pos)
{
	flashpoint();
	
	printf('# Displays special Japanese characters ');
	printf('# uses Alert() ');

	if(pos==0)
	writeMenu('"DisplayJpn"','"EXTRA"','"JBefore()"');
	else
	writeMenu('"DisplayJpn"','"EXTRA"','"JAfter()"');

	JSpecialAlert(0x80,0xde,pos);
	JSpecialAlert(0x80,0xdf,pos);
	
	JSpecialAlert(0x8a,0xde,pos);
	JSpecialAlert(0x8a,0xdf,pos);
	
	JSpecialAlert(0xaa,0xde,pos);
	JSpecialAlert(0xaa,0xdf,pos);
	
	JSpecialAlert(0xb6,0xde,pos);
	JSpecialAlert(0xb6,0xdf,pos);
	
	JSpecialAlert(0xbb,0xde,pos);
	JSpecialAlert(0xbb,0xdf,pos);

	JSpecialAlert(0xc0,0xde,pos);
	JSpecialAlert(0xc0,0xdf,pos);
	
	JSpecialAlert(0xca,0xde,pos);
	JSpecialAlert(0xca,0xdf,pos);
	
	JSpecialAlert(0xea,0xde,pos);
	JSpecialAlert(0xea,0xdf,pos);

	printf('exitscript');
}

function JSpecialAlert(start,eChar, when )
{
	
  	var var0, var1,var2,var3,var3,var4,var5,var6;
  	tchar = decTohex(eChar );


	var0 = decTohex(start) ;  		
  	var1 = decTohex(start+1) ;
  	var2 = decTohex(start+2) ;
  	var3 = decTohex(start+3) ;
  	var4 = decTohex(start+4) ;
  	  	
	if(when==0)
   	printf('Alert("',tchar+var0 ,tchar+var1, tchar+var2 , tchar+var3, tchar+var4 ,'")' ); 
	else
 	printf('Alert("',var0+tchar ,var1+tchar, var2+tchar , var3+tchar, var4 +tchar,'")' ); 

}




/* 
 * convert decimal to hexadecimal
 * only goo dfor 2 digit numbers?
 */
function decTohex(decimal)
{
	var remainder=0;
	var dividend=0;
	var dechex = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
	
	dividend = decimal / 16 ;
	dividend = Math.floor( dividend );
	dividend = Math.round( dividend );
	
	remainder = decimal % 16 ;
	remainder = Math.floor( remainder );
	remainder = Math.round( remainder );
	
	
	return number = "\\x" + dechex[dividend] + dechex[ remainder] ;
	
	




}
